package vip.xiaonuo.smzq.modular.nbfb.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.smzq.modular.nbfb.entity.param.NbfbSixParam;
import vip.xiaonuo.smzq.modular.nbfb.entity.param.NbfbThreeParam;
import vip.xiaonuo.smzq.modular.nbfb.entity.param.NbfbTwoParam;
import vip.xiaonuo.smzq.modular.nbfb.entity.vo.*;
import vip.xiaonuo.smzq.modular.nbfb.service.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 年报附表
 *
 * @author sqq
 * @since 2024-07-29
 */
@Api(tags = "年报附表")
@RestController
@RequestMapping("/nbfb/nbfbs")
@Validated
public class NbfbController {

    //年报附表1
    @Resource
    private INbfbOneService iNbfbOneService;
    //年报附表2
    @Resource
    private INbfbTwoService iNbfbTwoService;
    //年报附表3
    @Resource
    private INbfbThreeService iNbfbThreeService;
    //年报附表4
    @Resource
    private INbfbFourService iNbfbFourService;
    //年报附表5
    @Resource
    private INbfbFiveService iNbfbFiveService;
    //年报附表6
    @Resource
    private INbfbSixService iNbfbSixService;
    //年报附表7
    @Resource
    private INbfbSevenService iNbfbSevenService;
    //共伴生矿产
    @Resource
    private INbfbGbskcService iNbfbGbskcService;



    /**
     * 年报附表2
     * SQQ
     * @return
     */
    @ApiOperation(value = "查询年报附表2")
    @PostMapping(value = "getNbfbTwo")
    public CommonResult<List<NbfbTwoVo>> getNbfbTwo(@RequestBody NbfbTwoParam param) {
        return CommonResult.data(iNbfbTwoService.getNbfbTwo(param));
    }

    /**
     * 导出年报附表2
     * SQQ
     * @return
     */
    @ApiOperation(value = "导出年报附表2")
    @PostMapping(value = "exportNbfbTwo")
    public void exportNbfbTwo(@RequestBody NbfbTwoParam param, HttpServletResponse response) {
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("ContentType", "application/vnd.ms-excel");
        //response.setHeader("Content-Disposition", "attachment; filename=111.xlsx");
        response.setCharacterEncoding("UTF-8");
        iNbfbTwoService.exportNbfbTwo(param,response);
    }



    /**
     * 年报附表3
     * SQQ
     * @return
     */
    @ApiOperation(value = "查询年报附表3")
    @PostMapping(value = "getNbfbThree")
    public CommonResult<List<NbfbThreeVo>> getNbfbThree(@RequestBody NbfbThreeParam param) {
        return CommonResult.data(iNbfbThreeService.getNbfbThree(param));
    }

    /**
     * 导出年报附表3
     * SQQ
     * @return
     */
    @ApiOperation(value = "导出年报附表3")
    @PostMapping(value = "exportNbfbThree")
    public void exportNbfbThree(@RequestBody NbfbThreeParam param, HttpServletResponse response) {
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("ContentType", "application/vnd.ms-excel");
        //response.setHeader("Content-Disposition", "attachment; filename=111.xlsx");
        response.setCharacterEncoding("UTF-8");
        iNbfbThreeService.exportNbfbThree(param,response);
    }


    /**
     * 查询年报附表1
     *
     * @param nd
     * @param kclb
     * @author Kevin
     * @since 2024/7/31 9:50
     */
    @ApiOperation(value = "查询年报附表1")
    @GetMapping(value = "getNbfbOne/{nd}")
    public CommonResult<List<NbfbOneVo>> getNbfbOne(@ApiParam(name = "nd", value = "年度", required = true) @PathVariable("nd") Integer nd,
                                                    @ApiParam(name = "kclb", value = "矿产大类") @RequestParam(required = false) String kclb) {
        return CommonResult.data(iNbfbOneService.getNbfbOneList(nd, kclb));
    }

    /**
     * 导出年报附表1
     *
     * @param nd
     * @param kclb
     * @param response
     * @author Kevin
     * @since 2024/7/31 9:54
     */
    @ApiOperation(value = "导出年报附表1")
    @GetMapping(value = "exportNbfbOne/{nd}")
    public void exportNbfbOne(@ApiParam(name = "nd", value = "年度", required = true) @PathVariable("nd") Integer nd,
                              @ApiParam(name = "kclb", value = "矿产大类") @RequestParam(required = false) String kclb,
                              HttpServletResponse response) {
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("ContentType", "application/vnd.ms-excel");
        response.setCharacterEncoding("UTF-8");
        iNbfbOneService.exportNbfbOne(nd, kclb, response);
    }


    /**
     * 查询年报附表4
     *
     * @param param
     * @author Kevin
     * @since 2024/7/31 9:50
     */
    @ApiOperation(value = "查询年报附表4")
    @PostMapping(value = "getNbfbFour")
    public CommonResult<List<NbfbFourVo>> getNbfbFour(@RequestBody NbfbSixParam param) {

        return CommonResult.data(iNbfbFourService.getNbfbFourList(param));
    }

    /**
     * 导出年报附表4
     *
     * @param param
     * @param response
     * @author Kevin
     * @since 2024/7/31 9:54
     */
    @ApiOperation(value = "导出年报附表4")
    @PostMapping(value = "exportNbfbFour")
    public void exportNbfbFour(@RequestBody NbfbSixParam param,
                              HttpServletResponse response) {
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("ContentType", "application/vnd.ms-excel");
        response.setCharacterEncoding("UTF-8");
        iNbfbFourService.exportNbfbFour(param, response);
    }


    /**
     * 年报附表5
     * SQQ
     * @param nd 年度
     * @param kcdm  节点_矿产代码_统计对象
     * @return
     */
    @ApiOperation(value = "查询年报附表5")
    @GetMapping(value = "getNbfbFive/{nd}/{kcdm}")
    public CommonResult<List<NbfbFiveVo>> getNbfbFive(@PathVariable("nd") Integer nd,@PathVariable("kcdm") String kcdm) {
      return CommonResult.data(iNbfbFiveService.getNbfbFive(nd,kcdm));
    }

    /**
     * 导出年报附表5
     * SQQ
     * @param nd 年度
     * @param kcdm  节点_矿产代码_统计对象
     * @return
     */
    @ApiOperation(value = "导出年报附表5")
    @GetMapping(value = "exportNbfbFive/{nd}/{kcdm}")
    public void exportNbfbFive(@PathVariable("nd") Integer nd, @PathVariable("kcdm") String kcdm, HttpServletResponse response) {
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("ContentType", "application/vnd.ms-excel");
        //response.setHeader("Content-Disposition", "attachment; filename=111.xlsx");
        response.setCharacterEncoding("UTF-8");
        iNbfbFiveService.exportNbfbFive(nd,kcdm,response);
    }


    /**
     * 年报附表6
     * SQQ
     * @return
     */
    @ApiOperation(value = "查询年报附表6")
    @PostMapping(value = "getNbfbSix")
    public CommonResult<List<NbfbSixVo>> getNbfbSix(@RequestBody NbfbSixParam param) {
        return CommonResult.data(iNbfbSixService.getNbfbSix(param));
    }

    /**
     * 临时规模导出所有矿种的导出Excel
     */
    @ApiOperation("临时规模导出所有矿种的导出Excel")
    @PostMapping("/exportNbfbSixExcel")
    public void exportAllKcGmExcel(@RequestBody NbfbSixParam param ,HttpServletResponse response) {
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("ContentType", "application/vnd.ms-excel");
        response.setCharacterEncoding("UTF-8");
        iNbfbSixService.exportNbfbSixExcel(param,response);
    }



    /**
     * 查询年报附表7
     * SQQ
     * @return
     */
    @ApiOperation(value = "查询年报附表7")
    @PostMapping(value = "getNbfbSeven")
    public CommonResult<List<NbfbSevenVo>> getNbfbSeven(@RequestBody NbfbSixParam param) {
        return CommonResult.data(iNbfbSevenService.getNbfbSeven(param));
    }

    /**
     * 年报附表7导出
     * SQQ
     */
    @ApiOperation("年报附表7导出")
    @PostMapping("/exportNbfbSevenExcel")
    public void exportNbfbSevenExcel(@RequestBody NbfbSixParam param ,HttpServletResponse response) {
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("ContentType", "application/vnd.ms-excel");
        response.setCharacterEncoding("UTF-8");
        iNbfbSevenService.exportNbfbSevenExcel(param,response);
    }


    /**
     * 年报附表8
     * SQQ
     * @param nd 年度
     * @return
     */
    @ApiOperation(value = "年报附表8")
    @GetMapping(value = "getNbfbEight/{nd}")
    @ApiImplicitParam(name = "nd", value = "年度", required = true)
    public CommonResult<List<GbskcVo>> getNbfbEight(@PathVariable("nd") @NotNull(message = "类型不能为空") Integer nd) {
        return CommonResult.data(iNbfbGbskcService.getNbfbEight(nd));
    }


    /**
     * 导出年报附表8
     * SQQ
     * @param nd 年度
     * @return
     */
    @ApiOperation(value = "导出年报附表8")
    @GetMapping(value = "exportNbfbEightExcel/{nd}")
    public void exportNbfbEightExcel(@PathVariable("nd")  @NotNull(message = "类型不能为空") Integer nd,HttpServletResponse response) {
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("ContentType", "application/vnd.ms-excel");
        response.setCharacterEncoding("UTF-8");
        iNbfbGbskcService.exportNbfbEightExcel(nd,response);
    }
}
